clear all
set type double
set varabbrev on, perm

*** FILL IN MAIN PATH TO RUN CODE ***
global dropbox "..."

global folder "$dropbox/_0_bjps_replication"
global in "$folder/in"
global out "$folder/out"
global proc "$folder/proc"

global graph "$out/graph"
global table "$out/table"
global temp "`c(tmpdir)'"
**************************
u "$proc/survey_reg_base.dta", clear

factor dis_agree_regulate_1 dis_agree_regulate_2 small_b_regulate fire_employees unions_private regulations_work regulations_life, pcf

rotate

u "$proc/survey_reg_base.dta", clear
drop if single_SBO == 1

label var tax_exp "Tax Experience"
label var tax_sub "Tax Policy"

eststo clear
eststo A: reghdfe employer_SBO regulation tax_sub tax_exp social risk individual workethic [pweight = weight], absorb(i.age_group i.race_cat i.hispanic_latino i.gender2 i.total_income i.education_level2 i.region) 
	estadd local control = "X"

eststo B: reghdfe pid regulation tax_sub tax_exp social risk individual workethic [pweight = weight], absorb(i.age_group i.race_cat i.hispanic_latino i.gender2 i.total_income i.education_level2 i.region)
	estadd local control = "X"

eststo C: reghdfe biden_or regulation tax_sub tax_exp social risk individual workethic [pweight = weight], absorb(i.age_group i.race_cat i.hispanic_latino i.gender2 i.total_income i.education_level2 i.region) 
	estadd local control = "X"

*** TABLE 8 ***
esttab A B C using "$table/5_mechanism.tex", replace ///
		cells(b(fmt(%-10.3fc) star) se(par fmt(%-10.3fc))) ///
		stats(control N r2, fmt( 0 0 2)	///
		labels("Controls" "Observations" "R-squared"))	///
		mgroups("Employer SBO" "PID: Republican" "Trump over Biden",	///		
		pattern(1 1 1)		///		
		prefix(\multicolumn{@span}{c}{) suffix(}) span	) ///
		collabels(none) mlabels(none) label 

*****
u "$proc/survey_reg_base.dta", clear

drop if employer_SBO == 1

label var tax_exp "Tax Experience"
label var tax_sub "Tax Policy"

eststo clear
eststo A: reghdfe single_SBO regulation tax_sub tax_exp social risk individual workethic [pweight = weight], absorb(i.age_group i.race_cat i.hispanic_latino i.gender2 i.total_income i.education_level2 i.region) 
	estadd local control = "X"

eststo B: reghdfe pid regulation tax_sub tax_exp social risk individual workethic [pweight = weight], absorb(i.age_group i.race_cat i.hispanic_latino i.gender2 i.total_income i.education_level2 i.region)
	estadd local control = "X"

eststo C: reghdfe biden_or regulation tax_sub tax_exp social risk individual workethic [pweight = weight], absorb(i.age_group i.race_cat i.hispanic_latino i.gender2 i.total_income i.education_level2 i.region) 
	estadd local control = "X"

*** TABLE 9 ***
esttab A B C using "$table/5_mechanism_single.tex", replace ///
		cells(b(fmt(%-10.3fc) star) se(par fmt(%-10.3fc))) ///
		stats(control N r2, fmt( 0 0 2)	///
		labels("Controls" "Observations" "R-squared"))	///
		mgroups("Non-Employer SBO" "PID: Republican" "Trump over Biden",	///		
		pattern(1 1 1)		///		
		prefix(\multicolumn{@span}{c}{) suffix(}) span	) ///
		collabels(none) mlabels(none) label 
		
*************
u "$proc/survey_reg_base.dta", clear

eststo clear

eststo B: reghdfe pid single_SBO employer_SBO regulation [pweight = weight], absorb(i.age_group i.race_cat i.hispanic_latino i.gender2 i.total_income i.education_level2 i.region) 
 estadd local control = "X"

eststo D: reghdfe biden_or single_SBO employer_SBO regulation [pweight = weight], absorb(i.age_group i.race_cat i.hispanic_latino i.gender2 i.total_income i.education_level2 i.region) 
 estadd local control = "X"

*** TABLE 10 ***
esttab B D using "$table/5_test_reg_tax.tex", replace ///
		cells(b(fmt(%-10.3fc) star) se(par fmt(%-10.3fc))) ///
		stats(control N r2, fmt( 0 0 2)	///
		labels("Controls" "Observations" "R-squared"))	///
		mgroups("PID: Republican" "Trump over Biden",	///		
		pattern(1 1)		///		
		prefix(\multicolumn{@span}{c}{) suffix(}) span	) ///
		collabels(none) mlabels(none) label 
